package com.masterclient.app.modules.cart.holder;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.masterclient.app.R;
import com.masterclient.app.modules.cart.adapter.ShopCartAdapterListener;
import com.masterclient.app.modules.cart.beans.ShopCartCustomItemBean;

public class DisableHeadHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

    private TextView tvTitle;
    private ShopCartAdapterListener mListener;

    public DisableHeadHolder(ViewGroup itemView,ShopCartAdapterListener listener) {
        super(LayoutInflater.from(itemView.getContext()).inflate(R.layout.view_item_cart_disable_head, itemView, false));

        mListener = listener;
        tvTitle = this.itemView.findViewById(R.id.tvTitle);
        TextView tvClear = this.itemView.findViewById(R.id.tvClear);
        tvClear.setOnClickListener(this);
    }

    public void onBindViewHolder(ShopCartCustomItemBean itemBean) {
        if (itemBean == null) {
            return;
        }
        tvTitle.setText("失效商品(" + itemBean.disableNum + ")");
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.tvClear) {
            mListener.onClearDisableGoods();
        }
    }
}
